using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GamePiece : MonoBehaviour
{
    private int x;
    private int y;


    public PieceType Type { get => type;  }
    public GridManager Grid { get => grid;  }
    public int X { get => x; set
        {
            if (IsMovable())
            {
                x = value;
            }
        }
    }
    public int Y { get => y; set
        {
            if (IsMovable())
            {
                y = value;
            }
        }
    }
    public MovablePiece MovableComponent { get => movableComponent; }
    public ColorPiece ColorComponent { get => colorComponent;  }

    private PieceType type;

    private GridManager grid;
    private MovablePiece movableComponent;
    private ColorPiece colorComponent;
    private void Awake()
    {
        movableComponent = GetComponent<MovablePiece>();
        colorComponent = GetComponent<ColorPiece>();
    }
    public void Init(int _x,int _y,GridManager _grid,PieceType _type)
    {
        X = _x;
        this.Y = _y;
        this.grid = _grid;
        this.type = _type;
    }
    public bool IsMovable()
    {
        return movableComponent != null;
    }
    public bool IsColored()
    {
        return colorComponent != null;
    }
}
